package com.yhb.controller;

import com.yhb.controller.form.BoundPosForm;
import com.yhb.controller.vo.ArrayWrapperVo;
import com.yhb.model.PosManufacturer;
import com.yhb.model.User;
import com.yhb.service.MPosService;
import me.edzh.spring.bootstrap.annotations.CurrentUser;
import me.edzh.spring.bootstrap.annotations.EncryptedRequestBody;
import me.edzh.spring.bootstrap.annotations.NeedAuth;
import me.edzh.spring.bootstrap.controller.BaseController;
import me.edzh.spring.bootstrap.model.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/pos")
public class PosController extends BaseController {
    @Autowired
    private MPosService mPosService;



    @PostMapping("/bound")
    @NeedAuth
    public Response boundMPos(@EncryptedRequestBody BoundPosForm form, @CurrentUser User user) {
        mPosService.addBound(form.getChannelId(), form.getSn(), user.getId());
        return Response.ok();
    }

    @GetMapping("/list")
    @NeedAuth

    public Response<ArrayWrapperVo<PosManufacturer>> getPosList() {
        return Response.ok(ArrayWrapperVo.<PosManufacturer>builder()
                .fuckingList(new ArrayList<PosManufacturer>(){{
                    add(PosManufacturer.builder()
                            .id("4134d611-84b2-46fb-b582-045b258f441b")
                            .name("乐刷")
                            .downloadPage("https://h5.leshuazf.com/download_qr_happypay.html")
                            .build());
                }})
                .build());
    }
}
